package org.backend.controller;

import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.backend.pojo.dto.NotificationRequest;
import org.backend.pojo.entity.Product;
import org.backend.service.EmailService;
import org.backend.utils.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/email")
@Slf4j
public class EmailController {

    @Autowired
    private EmailService emailService;

    @PostMapping("/sendNotify")
    public ApiResponse<Void> sendVerifyCode(@RequestBody NotificationRequest notificationRequest) {
        log.info(notificationRequest.toString());
        try {
            emailService.sendNotify(notificationRequest.getProductList(), notificationRequest.getTransactionId());
            return ApiResponse.success(null);
        } catch (Exception e) {
            return ApiResponse.error(e.getMessage());
        }
    }


}
